// ==UserScript==
// @name         bili 获取AV号
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  bili 获取AV号
// @author       Laicy <240298098@qq.com>
// @compatible   chrome
// @include      *.bilibili.com/*
// @require      https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
// @grant        GM_xmlhttpRequest
// @grant        GM_download
// ==/UserScript==

(function() {
  'use strict';
  var button = "<a id='biliOK' style='position: fixed;z-index: 101;left: 0;top: 50%;margin-top: 44px;width: 28px;height: 100px;"+
    "border-top-right-radius: 2px;border-bottom-right-radius: 2px;background-color: #78deaa;transition: all .3s;"+
    "font-size: 12px;color: #fff;box-shadow: 0 6px 10px 0 rgba(134,253,138,0.4);padding: 8px 7px;line-height: 14px;box-sizing: border-box;"+
    "text-decoration: none;outline: none;cursor: pointer;'>查询当前AV号</a>";
    $('body').append(button);
})();

$('#biliOK').click(function() {
  let query = document.querySelector('meta[itemprop="url"]').getAttribute('content').split("/");   
  let id = query[query.length];    
  if (!id) {
    alert("当前视频的av号：" + query[query.length -1])
  } else {  
    alert("当前视频的av号：" + query[query.length])
  }
}
